package com.fun.feifun.modules.business.model.param;

import com.fun.feifun.base.BaseEntity;
import com.fun.feifun.base.utils.MD5Util;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
public class BusinessOrderSuccessParam {

    private static final long serialVersionUID=1L;



    @ApiModelProperty(value = "订单编码")
    @NonNull
    private String orderCode;

    @ApiModelProperty(value = "外部订单编号")
    @NonNull
    private String outsideOrderCode;

    @ApiModelProperty(value = "供货商编码")
    @NonNull
    private String supplierCode;


    @ApiModelProperty(value = "1成功 -1失败")
    @NonNull
    private Integer state;

    //sign=MD5(userid=xxxx&productid=xxxxxxx&price=xxxx&num=xxx&mobile=xxxxx&spordertime=xxxxxxx&sporderid=xxxxx&key=xxxxxxx).toUpperCase()
    @ApiModelProperty(value = "签名验证摘要串：MD5(supplierCode=xxxx&key=xxxxxxx)")
    @NonNull
    private String sign;

    @ApiModelProperty(value = "密匙")
    @NonNull
    private String secretKey;

    @ApiModelProperty(value = "时间戳")
    private Long timeStamp;

    public BusinessOrderSuccessParam() {

    }


    public String MD5Sign() {
        String encrypt ="";
        try {
            StringBuilder signStr = new StringBuilder();
            signStr.append("supplierCode="+this.getSupplierCode()+"&&");
            signStr.append("secretKey="+this.getSecretKey()+"&&");
            signStr.append("timeStamp="+this.getTimeStamp());
            encrypt = MD5Util.encrypt(signStr.toString());
        }catch (Exception e){
            e.printStackTrace();
        }
        return encrypt;
    }
}
